@extends('public.admin.layout') 
@section('header')
<h2>友链管理</h2>
@endsection
 
@section('content')
<div class="row">
    <div class="col-sm-12">
            <button type="button" class="btn  btn-primary btn-sm" data-toggle="modal" data-target="#addModal">
                    新增
            </button>
        <table id="example2" class="table table-bordered table-hover dataTable" role="grid" aria-describedby="example2_info">
            <thead>
                <tr role="row">
                    <th class="sorting_asc" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">
                        网站名称
                    </th>
                    <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">网站地址
                    </th>
                    <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending">权重
                    </th>
                    <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">更新时间
                    </th>
                    <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">备注
                    </th>
                    <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">操作
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach($list as $link)
                <tr role="row" class="data-row">
                    <td class="linkname">{{$link->linkname}}</td>
                    <td class="linkurl">{{$link->linkurl}}</td>
                    <td class="linkweight">{{$link->linkweight}}</td>
                    <td class="updatetime">{{  $link->times}}</td>
                    <td class="remarks">{{$link->remarks}}</td>
                    <td><button type="button" class="btn  btn-primary btn-sm" data-toggle="modal" data-target="#editModal">
                            编辑
                    </button><button type="button" class="btn btn-warning btn-sm ml5" data-toggle="modal" data-target="#deleteModal">
                            删除
                    </button> </td>
                </tr>
                @endforeach

            </tbody>
        </table>
        
        {{$list->links()}}
    </div>
</div>
@component('public.modal') @slot('modalId') editModal @endslot @slot('modalTitle') 编辑链接 @endslot @slot('actionUrl') {{route('admin.link.edit',['id'=>$link->id])}}
@endslot
    @include('admin.link.form')
 @endcomponent
 @component('public.modal') @slot('modalId') deleteModal @endslot
 @slot('modalTitle') 删除链接 @endslot @slot('actionUrl') {{route('admin.link.destroy',['id'=>$link->id])}} @endslot 
     @component('public.message')
         确定要删除该链接吗？ 
     @endcomponent 
 @endcomponent 
 @component('public.modal') @slot('modalId') addModal @endslot @slot('modalTitle') 新增链接 @endslot @slot('actionUrl') {{route('admin.link.add')}}
@endslot
@slot('method')
    POST
@endslot
    @include('admin.link.form')
 @endcomponent
@endsection

@section('script')
<script>
    $('#editModal').on('show.bs.modal',function(event){
              var button=$(event.relatedTarget)
              var id=button.data('id')
              var row=button.closest('.data-row')
              var name=row.children('.linkname').text()
              $('#linkname').val(name)
              $('#linkurl').val(row.children('.linkurl').text())
              $('#linkweight').val(row.children('.linkweight').text())
              $('#remarks').val(row.children('.remarks').text())
         
          })

</script>
@endsection